package com.nycreativity.elecreativity.entity.po

import java.math.BigDecimal
import com.baomidou.mybatisplus.annotation.IdType
import com.nycreativity.elecreativity.entity.BaseEntity
import com.baomidou.mybatisplus.annotation.TableId
import com.nycreativity.elecreativity.times
import com.nycreativity.elecreativity.util.BatchSQL
import java.time.LocalDateTime

/**
 * <p>
 *  订单item
 * </p>
 *
 * @author sxt && ttxxi
 * @since 2021-03-11
 */
class OrderItem(

    /**
     * 订单id
     */
    @BatchSQL.Column
    var orderId: Long? = null,

    /**
     * 创建者id
     */
    @BatchSQL.Column
    override var creator: Long? = null,

    /**
     * 商品id
     */
    var skuId: Long? = null,

    /**
     * 商品单价
     */
    var goodsPrice: BigDecimal = BigDecimal(0),

    /**
     * 商品数量
     */
    var goodsCount: Int = 0,

    /**
     * 创建时间
     */
    override var createTime: LocalDateTime? = null

) : BaseEntity(creator) {

    /**
     * id
     */
    @TableId(value = "id", type = IdType.AUTO)
    var id: Int? = null

    /**
     * 商品名称
     */
    var goodsName: String? = null

    /**
     * 总金额
     */
    var allAmount: BigDecimal = BigDecimal(0)
        private set
        get() = goodsPrice * goodsCount


    override

    fun toString(): String {
        return "OrderItem{" +
                "id=" + id +
                ", goodsId=" + skuId +
                ", goodsCount=" + goodsCount +
                ", goodsPrice=" + goodsPrice +
                ", allAmount=" + allAmount +
                ", ${super.toString()}}"
    }
}
